package com.ruoyi.web.controller.check;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.check.domain.HangAndLie;
import com.ruoyi.check.domain.ShouYeVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.check.domain.ECheckListFormItem;
import com.ruoyi.check.service.IECheckListFormItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检点子项Controller
 *
 * @author hugh.sun
 * @date 2023-03-23
 */
@RestController
@RequestMapping("/check/ite")
public class ECheckListFormItemController extends BaseController
{
    @Autowired
    private IECheckListFormItemService eCheckListFormItemService;

    /**
     * 查询检点子项列表
     */
    @PreAuthorize("@ss.hasPermi('check:ite:list')")
    @GetMapping("/list")
    public TableDataInfo list(ECheckListFormItem eCheckListFormItem)
    {
        startPage();
        List<ECheckListFormItem> list = eCheckListFormItemService.selectECheckListFormItemList(eCheckListFormItem);
        return getDataTable(list);
    }
    /**
     * 导出检点子项列表
     */
    @PreAuthorize("@ss.hasPermi('check:ite:export')")
    @Log(title = "检点子项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ECheckListFormItem eCheckListFormItem)
    {
        List<ECheckListFormItem> list = eCheckListFormItemService.selectECheckListFormItemList(eCheckListFormItem);
        ExcelUtil<ECheckListFormItem> util = new ExcelUtil<ECheckListFormItem>(ECheckListFormItem.class);
        util.exportExcel(response, list, "检点子项数据");
    }

    /**
     * 获取检点子项详细信息
     */

    @PreAuthorize("@ss.hasPermi('check:ite:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eCheckListFormItemService.selectECheckListFormItemById(id));
    }
    @GetMapping( "/hasakei")
    public List<HangAndLie> hasakei(ShouYeVo shouYeVo)
    {
        //拿到表名题名
        int select1 = shouYeVo.getSelect1();
        int select2 = shouYeVo.getSelect2();
        int input = shouYeVo.getInput();
        ShouYeVo shouYeVo1 = shouYeVo;
        HangAndLie hangAndLie = new HangAndLie();
        ArrayList<HangAndLie> hangAndLies = new ArrayList<>();
        return hangAndLies;
    }

    /**
     * 新增检点子项
     */
    @PreAuthorize("@ss.hasPermi('check:ite:add')")
    @Log(title = "检点子项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ECheckListFormItem eCheckListFormItem)
    {
        return toAjax(eCheckListFormItemService.insertECheckListFormItem(eCheckListFormItem));
    }

    /**
     * 修改检点子项
     */
    @PreAuthorize("@ss.hasPermi('check:ite:edit')")
    @Log(title = "检点子项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ECheckListFormItem eCheckListFormItem)
    {

        return toAjax(eCheckListFormItemService.updateECheckListFormItem(eCheckListFormItem));
    }

    /**
     * 删除检点子项
     */
    @PreAuthorize("@ss.hasPermi('check:ite:remove')")
    @Log(title = "检点子项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eCheckListFormItemService.deleteECheckListFormItemByIds(ids));
    }
}
